<%@ page import="cn.darkfire.web.POJO.Car1" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 0xdF
  Date: 2022/11/9
  Time: 11:19
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>用户列表界面</title>
</head>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<body>
<jsp:include page="IdeaProjects/servlet_learn/web/sy6/head.jsp"/>
<center>
    <div style="margin-top: 100px">
    <c:if test="${not empty cars}">
    <%--    对用户列表进行遍历--%>
        <table border="1">
            <tr>
                <th>序号</th>
                <th>ID</th>
                <th>车名</th>
                <th>类型</th>
                <th>价格</th>
            </tr>
            <c:forEach items="${cars}" var="car" varStatus="i">
                <tr>
                    <td>${i}+1</td>
                    <td>${car.getId()}</td>
                    <td>${car.getName()}</td>
                    <td>${car.getType()}</td>
                    <td>${car.getPrice()}</td>
                </tr>
            </c:forEach>


        </table>
    </c:if>
    <c:if test="${empty cars}">
        <h2 style="font-weight: bolder">汽车列表为空！</h2>
    </c:if>
    </div>
</center>
<%
//    List<Car> cars = (List<Car>)session.getAttribute("cars");
//    response.getOutputStream().print(cars.get(0).toString());
    String errMSg = (String)session.getAttribute("error");
    String sucMSg = (String)session.getAttribute("success");
    if(errMSg!=null&&errMSg.contains("删除")){
        out.print("<script>alert(\""+errMSg+"\");</script>");
        session.removeAttribute("error");
    }
    if(sucMSg!=null&&sucMSg.contains("删除")){
        out.print("<script>alert(\""+sucMSg+"\");</script>");
        session.removeAttribute("success");
    }
%>
</body>
</html>
